package com.monika.webservice.config;

import com.sun.tracing.ProbeName;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author:whh
 * @date: 2025-07-30 20:35
 * <p></p>
 */
@Configuration
@ImportResource(locations = {"classpath:META-INF/cxf/cxf.xml","classpath:configServices/*ApplicationContext.xml"})
public class CXFConfig {

    @Autowired
    SpringBus bus;



    @Bean(name = "cxfServletRegistration")
    public ServletRegistrationBean<CXFServlet> cxfServletRegistration(){
        ServletRegistrationBean<CXFServlet> registrationBean=new ServletRegistrationBean<>();
        CXFServlet cxfServlet=new CXFServlet();
        cxfServlet.setBus(bus);
        registrationBean.setServlet(cxfServlet);
        registrationBean.setName("cxfServlet");
        List<String> urlMapping = new ArrayList<>();
        urlMapping.add("/services/*");
        registrationBean.setUrlMappings(urlMapping);
        registrationBean.setLoadOnStartup(1);
        return registrationBean;

    }

}
